const express = require('express');
const router = express.Router();
const userController = require('../Controller/userController');
const { verifyToken } = require('../middleware/auth');

// 不需要验证的路由
router.post('/register', userController.registerUser);
router.post('/login', userController.loginUser);
router.post('/refresh-token', userController.refreshAccessToken); // 刷新令牌路由

// 需要验证的路由
router.get('/getUsers', verifyToken, userController.getAllUsers);
router.get('/searchFriends', verifyToken, userController.searchFriends);

// 好友相关路由
router.get('/friends', verifyToken, userController.getFriends); // 获取好友列表
router.post('/friend-requests', verifyToken, userController.sendFriendRequest); // 发送好友请求
router.get('/friend-requests', verifyToken, userController.getFriendRequests); // 获取好友请求列表
router.post('/friend-requests/:requestId/handle', verifyToken, userController.handleFriendRequest); // 处理好友请求
router.delete('/friends/:friendId', verifyToken, userController.deleteFriend); // 删除好友

router.post('/logout', verifyToken, userController.logout); // 注销路由

module.exports = router;